package com.itheima.tliaswebmanagement.service.Impl;

import com.itheima.tliaswebmanagement.mapper.TliasMapper;
import com.itheima.tliaswebmanagement.pojo.entity.Dept;
import com.itheima.tliaswebmanagement.service.TliasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description TliasServiceImpl
 * @Author ziguan ling
 * @Date 2025--01--02
 */

@Service
public class TliasServiceImpl implements TliasService {
    @Autowired
    private TliasMapper tliasMapper;

    @Override
    public List<Dept> queryAll() {
        List<Dept> depts = tliasMapper.selecttAll();
        return depts;

    }

    @Override
    public void removeList(Integer id) {
        tliasMapper.deletById(id);

    }

    @Override
    public void addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        tliasMapper.insert(dept);
    }

    @Override
    public Dept getinfo(Integer id) {
        return tliasMapper.getByid(id);
    }

    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        tliasMapper.update(dept);

    }

}